package cn.tedu.store.mapper;

import java.util.Date;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import cn.tedu.store.entity.User;

@RunWith(SpringRunner.class)
@SpringBootTest
public class UserMapperTestCase {
	
	@Autowired
	UserMapper mapper;
	
	@Test
	public void addUser() {
		User user = new User();
		user.setUsername("BBB");
		user.setPassword("rrr");
		Integer rows = mapper.addUser(user);
		System.err.println("rows="+rows);
	}
	
	@Test
	public void updatePassword() {
		Integer uid = 26;
		String password = "zhu";
		String modefiedUser = "朱上林";
		Date modefiedTime = new Date();
		Integer rows = mapper.updatePassword(uid, password, modefiedUser, modefiedTime);
		System.err.println("rows="+rows);
	}
	
	@Test
	public void updateInfo() {
		User user = new User();
		user.setUid(26);
		user.setPhone("1888888438");
		user.setEmail("8888@88.com");
		user.setGender(1);
		user.setModefiedUser("ADMIN");
		user.setModefiedTime(new Date());
		Integer rows = mapper.updateInfo(user);
		System.err.println("rows="+rows);
	}
	
	@Test
	public void findUserByName() {
		String username="root";
		User user = mapper.findUserByName(username);
		System.err.println(user);
	}
	
	@Test
	public void findByUid() {
		Integer uid=26;
		User user = mapper.findByUid(uid);
		System.err.println(user);
	}
	
	@Test
	public void updateAvatar() {
		Integer uid = 28;
		String avatar = "d:/1.jpg";
		String modefiedUser = "超级管理员";
		Date modefiedTime = new Date();
		Integer rows = mapper.updateAvatar(uid, avatar, modefiedUser, modefiedTime);
		System.err.println("rows="+rows);
	}

}
